package logic

import (
	"context"
	"serve/internal/global/model"
	"serve/internal/svc"
	"serve/videoSrv"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserLoginLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLoginLogic {
	return &UserLoginLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserLoginLogic) UserLogin(in *videoSrv.UserLoginRequest) (*videoSrv.UserLoginResponse, error) {
	// todo: add your logic here and delete this line
	var User = model.User{
		Account:  in.Account,
		Password: in.Password,
	}
	if err := model.DB.Where(&User).Find(&User).Error; err != nil {
		return nil, err
	}
	return &videoSrv.UserLoginResponse{
		UserId: int64(User.ID),
	}, nil
}
